<template>
  <view class="container">
    <view v-for="(item, index) in parentlist" :key="index" class="itembox" @click="changetabbarindex(index)">
      <image :src="item.selectedIconPath" mode="" v-if="tabbarindex == index" style="width: 44rpx; height: 44rpx"></image>
      <image :src="item.iconPath" mode="" v-else style="width: 44rpx; height: 44rpx"></image>
      <view :class="{ acttabber: tabbarindex == index }" v-if="tabbarindex == index">{{ item.text }}</view>
      <view v-else style="font-weight: 500; font-size: 24rpx; color: #999999">{{ item.text }}</view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    parentlist: Array,
    tabbarindex: Number
  },
  data() {
    return {
      // tabbarindex: 0
    };
  },
  methods: {
    // 切换tabbar的页面
    changetabbarindex(index) {
      // this.tabbarindex = index;
      this.$emit('changetabbar', index);
    }
  },
  created() {
    // console.log('tabbar页面的显示', this.currenttabberindex);
    // this.tabbarindex = this.currenttabberindex;
  }
};
</script>

<style lang="scss" scoped>
.container {
  box-sizing: border-box;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  position: fixed;
  bottom: 0;
  width: 750rpx;
  height: 100rpx;
  background-color: #fff;
  .itembox {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .acttabber {
    font-family: PingFang SC, PingFang SC;
    font-weight: bold;
    font-size: 24rpx;
    color: #3553e8;
  }
}
</style>
